home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
probo30.zip
/
ASSASSIN.PR
< prev
next >
Wrap
Text File
|
1993-02-28
|
4KB
|
105 lines
(**************************************************************************)
(* W A R N I N G *)
(* *)
(* This Robot has NOT been designed to take advantage of the advanced *)
(* features of P-ROBOTS, such as, Shields, Fuel, Teams or Obstructions. *)
(**************************************************************************)
PROCEDURE Assassin;
{ Based on a C-Robot by John R. Naleszkiewicz }
{ Scanning routine calls itself recursively with successively }
{ smaller scan widths until the opponent is destroyed or lost. }
{ This robot is always moving to a new random point. }
{ "Global" variables, can be used by any function or procedure }
VAR
x, y : Integer; { traveling toward this location }
travelCount : Integer; { change direction every so often }
Angle : Integer; { angle of travel for the robot }
hitAngle, hitRange : Integer; { used to pin-point opponent }
Switch : Boolean; { scanning increment TRUE = minus, FALSE = plus }
{ make sure the robot is moving in the right direction }
PROCEDURE evade;
BEGIN
travelCount := travelCount-1;
IF ((travelCount = 0) OR (speed < 51)) THEN
BEGIN
drive(Angle, 0); {Slow Down}
x := Random(800)+100;
y := Random(800)+100;
Angle := Angle_To(x, y);
travelCount := 4;
WHILE (speed > 49) DO {Nothing} ;
drive(Angle, 100);
END;
END; { end of evade }
FUNCTION NextHitAngle(increment : Integer) : Integer;
BEGIN
IF Switch THEN
NextHitAngle := hitAngle+increment
ELSE
NextHitAngle := hitAngle-increment;
END; { end of nextHitAngle }
{ scan and fire with increaseing resolution until target is lost }
PROCEDURE find_n_fire(width, missCount : Integer);
{ width: integer ; scan width }
{ missCount: integer ; how many scans before reversing direction }
VAR
width2 : Integer;
BEGIN
IF (width < 2) THEN
BEGIN
width := 2;
evade;
END;
width2 := width*2;
IF Switch THEN
hitAngle := hitAngle-width2*2
ELSE
hitAngle := hitAngle+width2*2;
hitRange := scan(NextHitAngle(width2), width);
missCount := missCount-1;
WHILE ((hitRange = 0) OR (hitRange > 700)) AND (missCount <> 0) DO
BEGIN
hitRange := scan(NextHitAngle(width2), width);
missCount := missCount-1;
END;
IF hitRange <> 0 THEN
BEGIN
cannon(hitAngle, hitRange);
find_n_fire((width DIV 2), 10);
END
ELSE
BEGIN
IF (scan(NextHitAngle(13), 10) = 0) THEN
BEGIN
Switch := NOT Switch;
IF Switch
THEN hitAngle := hitAngle+13
ELSE hitAngle := hitAngle-13;
END;
evade;
END;
END; { end of find_n_fire }
BEGIN {Assassin Main}
hitAngle := 0; { scanning angle }
Switch := True; { scanning increment direction }
travelCount := 0; { intialize travel count }
evade; { make sure movment is in the right direction }
REPEAT { loop is executed "forever" }
find_n_fire(8, 23); { find the opponent and shoot }
UNTIL Dead OR Winner;
END; { end of Assassin Main }